#include<bits/stdc++.h>
using namespace std;

typedef long long llong;
const int N=1e5+3;

int t;
int n,m,L,V;
int d[N],v[N],a[N];
int p[N];
pair<int,int> ovr[N];
int tot;

inline int find_in(int d){
    int l=1,r=m,ans=-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(p[mid]>=d){
            ans=mid;
            r=mid-1;
        }
        else
            l=mid+1;
    }
    return ans;
}

inline llong calc_v2(int v0,int a,int s){
    return v0*v0+2ll*a*s;
}

inline int find_end(int d,int v,int a){
    int l=1,r=m,ans=-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(p[mid]<d)
            l=mid+1;
        else{
            if(calc_v2(v,a,p[mid]-d)>V*V){
                ans=mid;
                l=mid+1;
            }
            else
                r=mid-1;
        }
    }
    return ans;
}

inline int find_begin(int d,int v,int a){
    int l=1,r=m,ans=-1;
    while(l<=r){
        int mid=(l+r)>>1;
        if(p[mid]<d)
            l=mid+1;
        else{
            if(calc_v2(v,a,p[mid]-d)>V*V){
                ans=mid;
                r=mid-1;
            }
            else
                l=mid+1;
        }
    }
    return ans;
}

inline bool cmp(pair<int,int> a,pair<int,int> b){
    if(a.second==b.second)
        return a.first<b.first;
    return a.second<b.second;
}

int main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin>>t;
    while(t--){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
        }
        for(int i=1;i<=m;i++)
            cin>>p[i];
        for(int i=1;i<=n;i++){
            if(a[i]<0){
                if(v[i]>V){
                    int f1=find_in(d[i]);
                    int f2=find_end(d[i],v[i],a[i]);
                    if(f1==-1||f2==-1) continue;
                    ovr[++tot]={f1,f2};
                }
            }
            else{
                int f=find_begin(d[i],v[i],a[i]);
                if(f!=-1)
                    ovr[++tot]={f,m};
            }
        }
        sort(ovr+1,ovr+tot+1,cmp);
        int need=0,p=0;
        for(int i=1;i<=tot;i++){
            if(p<ovr[i].first){
                p=ovr[i].second;
                need++;
            }
        }
        cout<<tot<<" "<<m-need<<endl;
        tot=0;
    }
    return 0;
}